package com.rop.znyx.home.controller;

import com.rop.znyx.common.auth.AuthContextHolder;
import com.rop.znyx.common.result.Result;
import com.rop.znyx.home.service.ItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created with IntelliJ IDEA
 * User: Rop
 * Date: 2023/7/21
 * Time: 13:35
 * Description:
 */

@Api(tags = "商品详情")
@RestController
@RequestMapping("api/home")
@RequiredArgsConstructor
public class ItemApiController {

    private final ItemService itemService;

    @ApiOperation(value = "获取sku详细信息")
    @GetMapping("item/{id}")
    public Result<Map<String, Object>> index(@PathVariable Long id, HttpServletRequest request) {
        Long userId = AuthContextHolder.getUserId();
        return Result.ok(itemService.item(id, userId));
    }
}
